package com.hlt.shuiliting.dao;

import java.util.List;
import java.util.Map;

import com.hlt.shuiliting.database.DBUtil;
import com.hlt.shuiliting.valuebean.BiaoDuan;

public class BiaoDuanDAO {

	private int updateCount;
	
	public List list(int GongChengXMID) {
		String sql = "select * from BiaoDuan where GongChengXMID = ?";
		Object[] params = {GongChengXMID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		List list = myDB.getResultSet();
		myDB.closed();
		
		return list;
	}
	
	public Map view(int id) {
		List list = null;
		String sql = "select * from BiaoDuan where ID = ?";
		Object[] params = {id};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		list = myDB.getResultSet();
		Map map = (Map)list.get(0);
		
		return map;
	}
	public int insert(BiaoDuan BiaoDuan) {
		String sql = "insert BiaoDuan values (seq_BiaoDuan.nextVal, ?, ?, to_date('?','yyyy-mm-dd'), ?,?, ?, ?, ?,?, ?, ?, ?, ?, to_date('?','yyyy-mm-dd'), to_date('?','yyyy-mm-dd'), ?,?)";
		String ZhuangTai = BiaoDuan.getZhuangTai();
		String JiLuSJ = BiaoDuan.getJiLuSJ();
		String LuRuR = BiaoDuan.getLuRuR();
		String BiaoDuanMC = BiaoDuan.getBiaoDuanMC();
		String FaBaoFS = BiaoDuan.getFaBaoFS();
		String ZhaoBiaoZZXS = BiaoDuan.getZhaoBiaoZZXS();
		String ZhaoBiaoSX = BiaoDuan.getZhaoBiaoSX();
		String ZhaoBiaoJDBM = BiaoDuan.getZhaoBiaoJDBM();
		String ZhaoBiaoDLJG = BiaoDuan.getZhaoBiaoDLJG();
		String ZhongBiaoDW = BiaoDuan.getZhongBiaoDW();
		String ZhongBiaoJG = BiaoDuan.getZhongBiaoJG();
		String HeTongJHZGQ = BiaoDuan.getHeTongJHZGQ();
		String JiHuaKGRQ = BiaoDuan.getJiHuaKGRQ();
		String JiHuaWGRQ = BiaoDuan.getJiHuaWGRQ();
		String QiYeID = BiaoDuan.getQiYeID();
		String GongChengXMID = BiaoDuan.getGongChengXMID();
		Object[] params = {ZhuangTai, JiLuSJ, LuRuR, BiaoDuanMC, FaBaoFS, ZhaoBiaoZZXS, ZhaoBiaoSX, ZhaoBiaoJDBM, ZhaoBiaoDLJG, ZhongBiaoDW, ZhongBiaoJG, HeTongJHZGQ, JiHuaKGRQ, JiHuaWGRQ, QiYeID, GongChengXMID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int update(BiaoDuan BiaoDuan) {
		String sql = "update BiaoDuan set ZhuangTai = ?, JiLuSJ = to_date('?','yyyy-mm-dd'), LuRuR = ?, BiaoDuanMC = ?, FaBaoFS = ?," +
				" ZhaoBiaoZZXS = ?, ZhaoBiaoSX = ?, ZhaoBiaoJDBM = ?, ZhaoBiaoDLJG = ?, " +
				"ZhongBiaoDW = to_date('?','yyyy-mm-dd'), ZhongBiaoJG = ?, HeTongJHZGQ = ?, " +
				"JiHuaKGRQ = to_date('?','yyyy-mm-dd'), JiHuaWGRQ = to_date('?','yyyy-mm-dd'), QiYeID = ?, GongChengXMID = ?, where ID = ?";
		String ID = BiaoDuan.getID();	
		String ZhuangTai = BiaoDuan.getZhuangTai();
		String JiLuSJ = BiaoDuan.getJiLuSJ();
		String LuRuR = BiaoDuan.getLuRuR();
		String BiaoDuanMC = BiaoDuan.getBiaoDuanMC();
		String FaBaoFS = BiaoDuan.getFaBaoFS();
		String ZhaoBiaoZZXS = BiaoDuan.getZhaoBiaoZZXS();
		String ZhaoBiaoSX = BiaoDuan.getZhaoBiaoSX();
		String ZhaoBiaoJDBM = BiaoDuan.getZhaoBiaoJDBM();
		String ZhaoBiaoDLJG = BiaoDuan.getZhaoBiaoDLJG();
		String ZhongBiaoDW = BiaoDuan.getZhongBiaoDW();
		String ZhongBiaoJG = BiaoDuan.getZhongBiaoJG();
		String HeTongJHZGQ = BiaoDuan.getHeTongJHZGQ();
		String JiHuaKGRQ = BiaoDuan.getJiHuaKGRQ();
		String JiHuaWGRQ = BiaoDuan.getJiHuaWGRQ();
		String QiYeID = BiaoDuan.getQiYeID();
		String GongChengXMID = BiaoDuan.getGongChengXMID();
		Object[] params = {ZhuangTai, JiLuSJ, LuRuR, BiaoDuanMC, FaBaoFS, ZhaoBiaoZZXS, ZhaoBiaoSX, ZhaoBiaoJDBM, ZhaoBiaoDLJG, ZhongBiaoDW, ZhongBiaoJG, HeTongJHZGQ, JiHuaKGRQ, JiHuaWGRQ, QiYeID, GongChengXMID, ID};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
	
	public int delete(int id) {
		String sql = "delete from BiaoDuan where ID = ?";
		Object[] params = {};
		DBUtil myDB = new DBUtil();
		myDB.doPstm(sql, params);
		updateCount = myDB.getUpdateCount();
		return updateCount;
	}
}
